<?php
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */

namespace Api\InterfaceApi\v1\Inventory;

use App\Inventory\Mapper\InventoryGoodsMapper;
use Mine\MineResponse;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;

/**
 * 测试-商品管理
 */
class GoodsApi
{

    /**
     * @var InventoryGoodsMapper
     */
    protected InventoryGoodsMapper $goods;

    protected MineResponse $response;

    /**
     * DemoApi constructor.
     * @param InventoryGoodsMapper $goods
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function __construct(InventoryGoodsMapper $goods)
    {
        $this->response = container()->get(MineResponse::class);
        $this->goods = $goods;
    }


    /**
     * 获取部门列表接口
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getGoodsList(): ResponseInterface
    {
        // 第二个参数，不进行数据权限检查，否则会拉起检测是否登录。
        return $this->response->success('请求成功', $this->goods->getPageList([], false));
    }
}
